#include <bits/stdc++.h>

#define in read()
#define fi first
#define se second
#define pb push_back
#define y1 y_alpha_1

using namespace std;

using ll = long long;
using db = double;
using vec = vector<int>;
using pii = pair<int,int>;

ll read() {
	ll x = 0; bool f = 0; char ch = getchar();
	while(!isdigit(ch)) f |= ch == '-',ch = getchar();
	while(isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48),ch = getchar();
	return f ? -x : x;
}

const int N = 20;
const int M = 5e5 + 10;
const int mod = 1e9 + 7;

ll n;
int K,b[N],top;
map <ll,ll> f[N][2][2];
vector<ll> a;

struct node { int x,y; friend bool operator < (node x,node y) { return (db) a[x.x] * a[x.y] < (db) a[y.x] * a[y.y]; }};

int main() {
#ifndef ONLINE_JUDGE
	freopen("1.in","r",stdin);
#endif
	n = in,K = in; for(ll x = n;x;x /= 10) b[++top] = x % 10; reverse(b + 1,b + top + 1);
	f[0][1][1][1] = 1; int o = 0;
	for(int i = 0;i < top;i++,o ^= 1) {
		for(int j = 0;j < 2;j++)
			for(int k = 0;k < 2;k++) {
				for(auto d : f[o][j][k]) {
					int low = j ? 0 : 1 , lim = k ? b[i + 1] : 9;
					for(int t = low;t <= lim;t++) {
						f[o ^ 1][j & (t == 0)][k & (t == lim)][d.fi * (t == 0 ? 1 : t)] += d.se;
					}
				}
				map <ll,ll> tmp; f[o][j][k].swap(tmp);
			}
	}
	map <ll,ll> tmp;
	for(int k = 0;k < 2;k++)
		for(auto d : f[o][0][k]) tmp[d.fi] += d.se;
	for(auto d : tmp) a.pb(d.se);
	sort(a.begin(),a.end(),greater<ll>());
	priority_queue < node > q;
	for(int i = 0;i < a.size();i++) q.push((node){i,0});
	ll ans = 0;
	while(q.size() && K) {
		node t = q.top(); int x = t.x,y = t.y; q.pop(); K--;
		ans += (ll) a[x] % mod * (a[y] % mod) % mod; ans %= mod;
		y++; if(y < a.size()) q.push((node){x,y});
	}
	printf("%lld\n",ans);
	return 0;
}
